package org.nanotek.tests.hibernate;

import org.nanotek.cms.domain.lucene.config.IndexConfig;
import org.nanotek.dao.DAO;
import org.nanotek.util.Base;
import org.nanotek.util.PersistenceBaseBeanBuilder;

@SuppressWarnings("hiding")
public class IndexConfigSpringBuilder <String , C extends IndexConfig> extends SpringBaseBuilder implements PersistenceBaseBeanBuilder<String,C> {

	@Override
	public Base<?> createBeanInstance(java.lang.String ref, Base<?> clazz) {
		return ctx.getBean(ref,clazz.getClass());
	}

	@Override
	public C persistBean(String r, C k) {
		@SuppressWarnings("unchecked")
		DAO<IndexConfig> dao = (DAO<IndexConfig>) ctx.getBean((java.lang.String) r);
		dao.persist(k);
		return k;
	}

	@Override
	public void deleteBean(String r, C k) {
		DAO<IndexConfig> dao = (DAO<IndexConfig>) ctx.getBean((java.lang.String) r);
		dao.delete(k);
	}

}
